package com.zhxy.manager.controller;

import com.zhxy.manager.entity.Canteen;
import com.zhxy.manager.service.intf.CanteenService;
import com.zhxy.manager.vo.PageBean;
import com.zhxy.manager.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: 花落云溪醉梦
 * @Date: 2022年03月31 20:22
 * @ClassName:
 * @Declare:
 */
//
@RestController
@RequestMapping("/api/canteen/")
public class CanteenController {

    @Autowired
    private CanteenService service;

    //    新增
    @PostMapping("save.do")
    public R save(Canteen canteen) {
        return service.save(canteen);
    }

    //    查询
    @GetMapping("page.do")
    public PageBean page(int page, int limit) {
        return service.queryPage(page, limit);
    }

    //      删除
    @PostMapping("del.do")
    public R del(int id) {
        return service.del(id);
    }

    //      批量删除
    @PostMapping("delBatch.do")
    public R del(@RequestBody int[] ids) {
        return service.delBatch(ids);
    }

    //      搜索
    @GetMapping("pagewhere.do")
    public PageBean page(String name, int flavour, int page, int limit) {
        return service.queryPageWhere(name, flavour, page, limit);
    }
//      修改
    @PostMapping("update.do")
    public R update(Canteen canteen){
        return service.update(canteen);
    }
}
